// ... 展开剩余

function sum(...numbers: number[]): number {
  // let total = 0;
  // for (let i = 0; i < numbers.length; i++) {
  //   total += numbers[i];
  // }
  // return total;

  return numbers.reduce((ac, cu) => {
    return ac + cu;
  }, 0);
}

console.log(sum(1, 2, 3, 4, 5));

const nu1 = [5, 7, 8];
const nu2 = [9, 10, 20, 5, 13];
const finalNumbers = nu1.concat(nu2);
console.log(finalNumbers);

const [firstName, ...rest] = ["hello", "world", "666", "jason", "279ih"];
console.log(firstName);
console.log(rest);

const obj = {
  name: "asdi",
  age: 20,
  money: 300,
};

const { name: fName, ...rest1 } = obj;
console.log(fName);
console.log(rest1);
